package com.seeyon.apps.reimburseplugin.listener;

import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.alibaba.fastjson.JSONObject;
import com.seeyon.apps.collaboration.event.CollaborationFinishEvent;
import com.seeyon.apps.collaboration.po.ColSummary;
import com.seeyon.apps.reimburseplugin.dao.ReimburseDao;
import com.seeyon.apps.reimburseplugin.dao.ReimburseSonDao;
import com.seeyon.apps.reimburseplugin.po.ConvertTempPo;
import com.seeyon.apps.reimburseplugin.po.ConvertTempSonPo;
import com.seeyon.apps.reimburseplugin.po.Reimbursement;
import com.seeyon.apps.reimburseplugin.po.ReimbursementSon;
import com.seeyon.apps.reimburseplugin.po.TemporaryPO;
import com.seeyon.apps.reimburseplugin.po.TemporarySonPO;
import com.seeyon.apps.reimburseplugin.util.HttpUtils;
import com.seeyon.ctp.common.AppContext;
import com.seeyon.ctp.common.po.affair.CtpAffair;
import com.seeyon.ctp.common.po.ctpenumnew.CtpEnumItemPO;
import com.seeyon.ctp.common.po.filemanager.Attachment;
import com.seeyon.ctp.common.po.template.CtpTemplate;
import com.seeyon.ctp.event.EventTriggerMode;
import com.seeyon.ctp.organization.manager.OrgManager;
import com.seeyon.ctp.organization.po.OrgPost;
import com.seeyon.ctp.organization.po.OrgPrincipal;
import com.seeyon.ctp.organization.po.OrgUnit;
import com.seeyon.ctp.util.annotation.ListenEvent;
import com.seeyon.v3x.dee.common.base.util.DateUtils;

import www.seeyon.com.utils.json.JSONUtils;




public class ReimburseListener {
	private static final Log logger=LogFactory.getLog(ReimburseListener.class);
	private ReimburseDao reimburseDao=(ReimburseDao)AppContext.getBean("reimburseDao");
	private ReimburseSonDao reimburseSonDao=(ReimburseSonDao)AppContext.getBean("reimburseSonDao");
	private OrgManager orgManager =(OrgManager)AppContext.getBean("orgManager");
	@ListenEvent(event = CollaborationFinishEvent.class,mode=EventTriggerMode.afterCommit)
	public void dealReimbursement(CollaborationFinishEvent event){
		logger.info("==============CollaborationFinishEvent");
		try {
			//查询事项表
			CtpAffair ctpAffair=reimburseDao.findAffairByObjId(event.getSummaryId().toString());
			//查询模板表
			CtpTemplate ctpTemplate=reimburseDao.findTemplate(ctpAffair.getTempleteId().toString());
			//模板编号
			String templateNum=ctpTemplate.getTempleteNumber();
			if ("clfbx01".equals(templateNum)||"clfbx02".equals(templateNum)) {
				String formRecordId=event.getSummary().getFormRecordid().toString();
				logger.info("==============formrecordid:"+formRecordId);
				//根据表单记录id查询对应字典表的记录
				TemporaryPO temporaryPO=reimburseDao.findReimburseById(Long.valueOf(formRecordId));
				logger.info("===================1");
				
				Map<String, Object> resMap=getNewTemp(temporaryPO);
				logger.info("===================2");
				Map<String, Object> mainMap=new HashMap<String, Object>();
				mainMap.put("mainData", resMap.get("convertPO"));
				//附件信息
				ColSummary colSummary=event.getSummary();
				List<Attachment> attList=reimburseDao.attachmentList(colSummary.getId().toString());
				StringBuilder sbr=new StringBuilder();
				StringBuilder filenames=new StringBuilder();
				if (attList!=null&&attList.size()>0) {
					for(int i=0;i<attList.size();i++) {
						Attachment attachment=attList.get(i);
						String attName=attachment.getFilename();
						String att=attachment.getFileUrl()+"";
						if (i==0) {
							sbr.append(att);
							filenames.append(attName);
						}else {
							sbr.append("|"+att);
							filenames.append("|"+attName);
						}
					}
					mainMap.put("attachmentNum", attList.size());
					mainMap.put("attachmentName", filenames.toString());
					mainMap.put("attachmentId", sbr.toString());
				}else {
					mainMap.put("attachmentNum",0);
					mainMap.put("attachmentName", "");
					mainMap.put("attachmentId", "");
				}
				TemporaryPO po=(TemporaryPO)resMap.get("tempPO");
				//根据表单记录id查询
				List<TemporarySonPO> sonPOList=reimburseSonDao.findReimburseList(Long.valueOf(formRecordId));
				logger.info("===================3");
				List<TemporarySonPO> newSonList=null;
				if (sonPOList!=null&&sonPOList.size()>0) {
					List<ConvertTempSonPo> sonList=new ArrayList<ConvertTempSonPo>();
					newSonList=getNewsonList(sonPOList,po,sonList);
					mainMap.put("details", sonList);
					logger.info("===================3-1");
				}
				logger.info("===================4");
				String json=JSONObject.toJSONString(mainMap);
				
				System.out.println(json);
				logger.info("------------------------报销json："+json);
				//调用第三方接口
				String url=AppContext.getSystemProperty("reimburseplugin.interfaceUrl");
				String newUrl=url+"?service=comfirm&urid=oa&pwd=oa";
				String code=new HttpUtils().httpPost(newUrl, json);
				logger.info("------------------------接口返回结果："+code);
				//接口调用后，将表单信息保存至有关报销的主表和子表
				this.saveInfo(po, newSonList,code);
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	public void saveInfo(TemporaryPO newTemp,List<TemporarySonPO> sonList,String code) {
		Reimbursement reimbursement=new Reimbursement();
		reimbursement.setIdIfNew();
		reimbursement.setStartDept(newTemp.getStartDept());
		reimbursement.setEvectionReason(newTemp.getEvectionReason());
		reimbursement.setEvectionPerson(newTemp.getEvectionPerson());
		reimbursement.setPost(newTemp.getPost());
		reimbursement.setAttachments(newTemp.getAttachments());
		reimbursement.setTotalTravelCosts(newTemp.getTotalTravelCosts());
		reimbursement.setTotalMealsDays(newTemp.getTotalMealsDays());
		reimbursement.setTotalMealsStandard(newTemp.getTotalMealsStandard());
		reimbursement.setTotalMealsNumber(newTemp.getTotalMealsNumber());
		reimbursement.setTotalMealsAmount(newTemp.getTotalMealsAmount());
		reimbursement.setTotalTravelcostsStandard(newTemp.getTotalTravelcostsStandard());
		reimbursement.setTotalTravelcostsDays(newTemp.getTotalTravelcostsDays());
		reimbursement.setTotalTravelcostsNumber(newTemp.getTotalTravelcostsNumber());
		reimbursement.setTotalTravelcostsAmount(newTemp.getTotalTravelcostsAmount());
		reimbursement.setTotalHotelExpense(newTemp.getTotalHotelExpense());
		reimbursement.setTotalOtherExpense(newTemp.getTotalOtherExpense());
		reimbursement.setTotalSubtotal(newTemp.getTotalSubtotal());
		reimbursement.setTotalMeetingFees(newTemp.getTotalMeetingFees());
		reimbursement.setTotal(newTemp.getTotal());
		reimbursement.setTotalCapital(newTemp.getTotalCapital());
		reimbursement.setAmount(newTemp.getAmount());
		reimbursement.setDates(DateUtils.parseDate(newTemp.getDates(), "yyyy-MM-dd HH:mm:ss"));
		reimbursement.setBudgetItem(newTemp.getBudgetItem());
		reimbursement.setBudgetDept(newTemp.getBudgetDept());
		reimbursement.setBudgetNature(newTemp.getBudgetNature());
		reimbursement.setFundsNature(newTemp.getFundsNature());
		reimbursement.setPkGroup(newTemp.getPkGroup());
		reimbursement.setTaxAmount(newTemp.getTaxAmount());
		reimbursement.setGlobalbbje(newTemp.getGlobalbbje());
		reimbursement.setOrgtaxAmount(newTemp.getOrgtaxAmount());
		reimbursement.setSxbz(newTemp.getSxbz());
		reimbursement.setBzbm(newTemp.getBzbm());
		reimbursement.setPayflag(newTemp.getPayflag());
		reimbursement.setOperator(newTemp.getOperator());
		reimbursement.setPkOrg(newTemp.getPkOrg());
		reimbursement.setVatAmount(newTemp.getVatAmount());
		reimbursement.setPkFiorg(newTemp.getPkFiorg());
		reimbursement.setBbje(newTemp.getBbje());
		reimbursement.setFydwbm(newTemp.getFydwbm());
		reimbursement.setGroupBbje(newTemp.getGroupBbje());
		reimbursement.setTniAmount(newTemp.getTniAmount());
		reimbursement.setDjdl(newTemp.getDjdl());
		reimbursement.setSpzt(newTemp.getSpzt());
		reimbursement.setDjbh(newTemp.getDjbh());
		reimbursement.setReceiver(newTemp.getReceiver());
		reimbursement.setJsfs(newTemp.getJsfs());
		reimbursement.setOrgtniAmount(newTemp.getOrgtniAmount());
		reimbursement.setDjrq(newTemp.getDjrq());
		reimbursement.setPayTarget(newTemp.getPayTarget());
		reimbursement.setPkPayorg(newTemp.getPkPayorg());
		reimbursement.setDjzt(newTemp.getDjzt());
		reimbursement.setDjlxbm(newTemp.getDjlxbm());
		reimbursement.setDwbm(newTemp.getDwbm());
		reimbursement.setOrgvatAmount(newTemp.getOrgvatAmount());
		reimbursement.setPkOrgv(newTemp.getPkOrgv());
		reimbursement.setYbje(newTemp.getYbje());
		reimbursement.setPkBilltype(newTemp.getPkBilltype());
		reimbursement.setCreateTime(new Date());
		if ("1".equals(code)) {
			reimbursement.setFlag("1");//接口调用返回成功
		}else {
			reimbursement.setFlag("-1");
		}
		
		boolean poFlag=reimburseDao.saveReimbursement(reimbursement);
		int count=0;
		if (poFlag) {
			count++;
			logger.info("----------------------报销主表信息保存成功，id："+reimbursement.getId());
			for(TemporarySonPO PO:sonList) {
				ReimbursementSon son=new ReimbursementSon();
				son.setIdIfNew();
				son.setReimbursementId(reimbursement.getId());
				son.setStartTime(DateUtils.stringToDate(PO.getStartTime()));
				son.setEndTime(DateUtils.stringToDate(PO.getEndTime()));
				son.setStartPlace(PO.getStartPlace());
				son.setEndPlace(PO.getEndPlace());
				son.setTransport(PO.getTransport());
				son.setTravelCosts(PO.getTravelCosts());
				son.setMealsDays(PO.getMealsDays());
				son.setMealsStandard(PO.getMealsStandard());
				son.setMealsNumber(PO.getMealsNumber());
				son.setMealsAmount(PO.getMealsAmount());
				son.setTravelCostsDays(PO.getTravelCostsDays());
				son.setTravelCostsStandard(PO.getTravelCostsStandard());
				son.setTravelCostsNumber(PO.getTravelCostsNumber());
				son.setTravelCostsAmount(PO.getTravelCostsAmount());
				son.setHotelExpense(PO.getHotelExpense());
				son.setOtherExpense(PO.getOtherExpense());
				son.setSubtotal(PO.getSubtotal());
				son.setMeetingFees(PO.getMeetingFees());
				son.setSonTotal(PO.getSonTotal());
				son.setRemark(PO.getRemark());
				son.setTaxAmount(PO.getTaxAmount());
				son.setJsfs(PO.getJsfs());
				son.setOrgtniAmount(PO.getOrgtniAmount());
				son.setGlobalBbje(PO.getGlobalBbje());
				son.setDeptId(PO.getDeptId());
				son.setOrgtaxAmount(PO.getOrgtaxAmount());
				son.setDwbm(PO.getDwbm());
				son.setVatAmount(PO.getVatAmount());
				son.setZfybje(PO.getZfybje());
				son.setCjkybje(PO.getCjkybje());
				son.setBbje(PO.getBbje());
				son.setOrgvatAmount(PO.getOrgvatAmount());
				son.setSzxmid(PO.getSzxmid());
				son.setSzxmname(PO.getSzxmname());
				son.setGroupBbje(PO.getGroupBbje());
				son.setTniAmount(PO.getTniAmount());
				son.setYbje(PO.getYbje());
				son.setJkbxr(PO.getJkbxr());
				son.setZfbbje(PO.getZfbbje());
				son.setCreateTime(new Date());
				boolean sonpoFlag=reimburseSonDao.saveReimbursementSon(son);
			}
		}
	}
	public List<TemporarySonPO> getNewsonList(List<TemporarySonPO> list,TemporaryPO po,List<ConvertTempSonPo> sonList) throws Exception{
		List<TemporarySonPO> newList=new ArrayList<TemporarySonPO>();
		for(TemporarySonPO sonPO:list) {
			logger.info("--------------------交通工具："+sonPO.getTransport());
			TemporarySonPO son=new TemporarySonPO();
			son.setReimbursementId(po.getId());
			son.setStartTime(getDates(sonPO.getStartTime()));
			son.setEndTime(getDates(sonPO.getEndTime()));
			son.setStartPlace(sonPO.getStartPlace());
			son.setEndPlace(sonPO.getEndPlace());
			String jtfs=sonPO.getTransport();
			//查询交通方式枚举值
			CtpEnumItemPO jtfsitem=reimburseDao.findEnumById(Long.valueOf(jtfs));
			if (jtfsitem!=null) {
				son.setTransport(jtfsitem.getShowvalue());
			}else {
				son.setTransport(jtfs);
			}
			son.setTravelCosts(sonPO.getTravelCosts());
			son.setMealsDays(sonPO.getMealsDays());
			son.setMealsStandard(sonPO.getMealsStandard());
			son.setMealsNumber(sonPO.getMealsNumber());
			son.setMealsAmount(sonPO.getMealsAmount());
			son.setTravelCostsDays(sonPO.getTravelCostsDays());
			son.setTravelCostsStandard(sonPO.getTravelCostsStandard());
			son.setTravelCostsNumber(sonPO.getTravelCostsNumber());
			son.setTravelCostsAmount(sonPO.getTravelCostsAmount());
			son.setHotelExpense(sonPO.getHotelExpense());
			son.setOtherExpense(sonPO.getOtherExpense());
			son.setSubtotal(sonPO.getSubtotal());
			son.setMeetingFees(sonPO.getMeetingFees());
			son.setSonTotal(sonPO.getSonTotal());
			son.setRemark(sonPO.getRemark());
			son.setTaxAmount(sonPO.getTaxAmount());
			son.setJsfs("4");
			son.setOrgtniAmount(sonPO.getSonTotal());
			son.setGlobalBbje(sonPO.getSonTotal());
			son.setDeptId(po.getBudgetDept());
			son.setOrgtaxAmount(null);
			son.setDwbm("0001");
			son.setVatAmount(sonPO.getSonTotal());
			son.setZfybje(son.getSonTotal());
			son.setCjkybje(null);
			son.setBbje(sonPO.getSonTotal());
			son.setOrgvatAmount(sonPO.getSonTotal());
			String xmCode="";
			String xmName="";
			//用于收支项目参数的传值，格式：编码-名称
			String fundsNature=po.getFundsNature();
			if (fundsNature!=null&&!"".equals(fundsNature)) {
				String[] xmArr=fundsNature.split("-");
				xmCode=xmArr[0];
				xmName=xmArr[1];
			}
			son.setSzxmid(xmCode);
			son.setSzxmname(xmName);
			son.setGroupBbje(sonPO.getSonTotal());
			son.setTniAmount(sonPO.getSonTotal());
			son.setYbje(sonPO.getSonTotal());
			son.setJkbxr(po.getEvectionPerson());
			son.setZfbbje(sonPO.getSonTotal());
			newList.add(son);
			//--------------------
			ConvertTempSonPo convertTempSonPo=new ConvertTempSonPo();
			convertTempSonPo.setReimbursementId(po.getId());
			convertTempSonPo.setStartTime(getDates(sonPO.getStartTime()));
			convertTempSonPo.setEndTime(getDates(sonPO.getEndTime()));
			convertTempSonPo.setStartPlace(sonPO.getStartPlace());
			convertTempSonPo.setEndPlace(sonPO.getEndPlace());
			//枚举值
			convertTempSonPo.setTransport(son.getTransport());
			convertTempSonPo.setTravelCosts(sonPO.getTravelCosts());
			convertTempSonPo.setMealsDays(sonPO.getMealsDays());
			convertTempSonPo.setMealsStandard(sonPO.getMealsStandard());
			convertTempSonPo.setMealsNumber(sonPO.getMealsNumber());
			convertTempSonPo.setMealsAmount(sonPO.getMealsAmount());
			convertTempSonPo.setTravelCostsDays(sonPO.getTravelCostsDays());
			convertTempSonPo.setTravelCostsStandard(sonPO.getTravelCostsStandard());
			convertTempSonPo.setTravelCostsNumber(sonPO.getTravelCostsNumber());
			convertTempSonPo.setTravelCostsAmount(sonPO.getTravelCostsAmount());
			convertTempSonPo.setHotelExpense(sonPO.getHotelExpense());
			convertTempSonPo.setOtherExpense(sonPO.getOtherExpense());
			convertTempSonPo.setSubtotal(sonPO.getSubtotal());
			convertTempSonPo.setMeetingFees(sonPO.getMeetingFees());
			convertTempSonPo.setSonTotal(sonPO.getSonTotal());
			convertTempSonPo.setRemark(sonPO.getRemark());
			convertTempSonPo.setTaxAmount(sonPO.getTaxAmount());
			convertTempSonPo.setJsfs("4");
			convertTempSonPo.setOrgtniAmount(sonPO.getSonTotal());
			convertTempSonPo.setGlobalBbje(sonPO.getSonTotal());
			convertTempSonPo.setDeptId(po.getBudgetDept());
			convertTempSonPo.setOrgtaxAmount(null);
			convertTempSonPo.setDwbm("0001");
			convertTempSonPo.setVatAmount(sonPO.getSonTotal());
			convertTempSonPo.setZfybje(son.getSonTotal());
			convertTempSonPo.setCjkybje(null);
			convertTempSonPo.setBbje(sonPO.getSonTotal());
			convertTempSonPo.setOrgvatAmount(sonPO.getSonTotal());
			convertTempSonPo.setSzxmid(xmCode);
			convertTempSonPo.setSzxmname(xmName);
			convertTempSonPo.setGroupBbje(sonPO.getSonTotal());
			convertTempSonPo.setTniAmount(sonPO.getSonTotal());
			convertTempSonPo.setYbje(sonPO.getSonTotal());
			convertTempSonPo.setJkbxr(po.getEvectionPerson());
			convertTempSonPo.setZfbbje(sonPO.getSonTotal());
			sonList.add(convertTempSonPo);
		}
		return newList;
	}
	public Map<String, Object> getNewTemp(TemporaryPO temporaryPO) throws Exception {
		OrgPrincipal orgPrincipal=reimburseDao.findOrgPrincipalByMemId(temporaryPO.getEvectionPerson());
		List<OrgUnit> list=reimburseDao.findOrgUnitByAccountId(Long.valueOf(temporaryPO.getStartDept()));
		
		CtpEnumItemPO ctpEnumItem=reimburseDao.findEnumById(Long.valueOf(temporaryPO.getFundsNature()));
		
		Map<String, Object> map=new HashMap<String, Object>();
		TemporaryPO tempPO=new TemporaryPO();
		ConvertTempPo convertTempPo=new ConvertTempPo();//用于构建接口传递参数
		tempPO.setId(temporaryPO.getId());
		if (ctpEnumItem!=null) {
			logger.info("==============经费性质："+ctpEnumItem.getShowvalue());
			tempPO.setFundsNature(ctpEnumItem.getShowvalue());
			convertTempPo.setFundsNature(ctpEnumItem.getShowvalue());
		}
		if (list!=null) {
			OrgUnit orgUnit=list.get(0);
			String code=orgUnit.getCode();
			logger.info("=========unitcode:"+code);
			tempPO.setStartDept(orgUnit.getCode());
			tempPO.setBudgetDept(orgUnit.getCode());
			convertTempPo.setStartDept(orgUnit.getCode());
			convertTempPo.setBudgetDept(orgUnit.getCode());
		}
		tempPO.setEvectionReason(temporaryPO.getEvectionReason());
		convertTempPo.setEvectionReason(temporaryPO.getEvectionReason());
		if (orgPrincipal!=null) {
			String memcode=orgPrincipal.getLoginName();
			logger.info("=========memcode:"+memcode);
			tempPO.setEvectionPerson(memcode);
			tempPO.setOperator(memcode);
			tempPO.setReceiver(memcode);
			convertTempPo.setEvectionPerson(memcode);
			convertTempPo.setOperator(memcode);
			convertTempPo.setReceiver(memcode);
		}
		String postStr=temporaryPO.getPost();
		if (postStr!=null&&!"".equals(postStr)) {
			OrgPost orgPost=reimburseDao.findPostById(Long.valueOf(postStr));
			if (orgPost!=null) {
				tempPO.setPost(orgPost.getName());
				convertTempPo.setPost(orgPost.getName());
			}
		}
		tempPO.setTotalTravelCosts(temporaryPO.getTotalTravelCosts());
		tempPO.setTotalMealsDays(temporaryPO.getTotalMealsDays());
		tempPO.setTotalMealsStandard(temporaryPO.getTotalMealsStandard());
		tempPO.setTotalMealsNumber(temporaryPO.getTotalMealsNumber());
		tempPO.setTotalMealsAmount(temporaryPO.getTotalMealsAmount());
		tempPO.setTotalTravelcostsStandard(temporaryPO.getTotalTravelcostsStandard());
		tempPO.setTotalTravelcostsDays(temporaryPO.getTotalTravelcostsDays());
		tempPO.setTotalTravelcostsNumber(temporaryPO.getTotalTravelcostsNumber());
		tempPO.setTotalTravelcostsAmount(temporaryPO.getTotalTravelcostsAmount());
		tempPO.setTotalHotelExpense(temporaryPO.getTotalHotelExpense());
		tempPO.setTotalOtherExpense(temporaryPO.getTotalOtherExpense());
		tempPO.setTotalSubtotal(temporaryPO.getTotalSubtotal());
		tempPO.setTotalMeetingFees(temporaryPO.getTotalMeetingFees());
		tempPO.setTotal(temporaryPO.getTotal());
		tempPO.setTotalCapital(temporaryPO.getTotalCapital());
		tempPO.setAmount(temporaryPO.getAmount());
		tempPO.setDates(DateUtils.dateToString(new Date(),"yyyy-MM-dd HH:mm:ss"));
		tempPO.setBudgetItem(temporaryPO.getBudgetItem());
		tempPO.setBudgetNature(temporaryPO.getBudgetNature());
		tempPO.setAttachments(temporaryPO.getAttachments());
		
		tempPO.setPkGroup("001");
		tempPO.setTaxAmount(null);
		tempPO.setGlobalbbje(temporaryPO.getAmount());
		tempPO.setOrgtaxAmount(null);
		tempPO.setSxbz("0");
		tempPO.setBzbm("CNY");
		tempPO.setPayflag("1");
		
		tempPO.setPkOrg("0001");
		tempPO.setVatAmount(temporaryPO.getAmount());
		tempPO.setPkFiorg("0001");
		tempPO.setBbje(temporaryPO.getAmount());
		tempPO.setFydwbm("0001");
		tempPO.setGroupBbje(temporaryPO.getAmount());
		tempPO.setTniAmount(temporaryPO.getAmount());
		tempPO.setDjdl("bx");
		tempPO.setSpzt("1");
		tempPO.setDjbh(null);
		tempPO.setJsfs(null);
		tempPO.setOrgtniAmount(temporaryPO.getAmount());
		tempPO.setDjrq(null);
		tempPO.setPayTarget("0");
		tempPO.setPkPayorg("0001");
		tempPO.setDjzt("1");
		tempPO.setDjlxbm(null);//交易类型编码
		tempPO.setDwbm("0001");
		tempPO.setOrgvatAmount(temporaryPO.getAmount());
		tempPO.setPkOrgv("0001");
		tempPO.setYbje(temporaryPO.getAmount());
		tempPO.setPkBilltype("2641");
		tempPO.setZyx2(temporaryPO.getZyx2());
		//-------------
		convertTempPo.setAttachments(temporaryPO.getAttachments());
		convertTempPo.setTotalTravelCosts(temporaryPO.getTotalTravelCosts());
		convertTempPo.setTotalMealsDays(temporaryPO.getTotalMealsDays());
		convertTempPo.setTotalMealsStandard(temporaryPO.getTotalMealsStandard());
		convertTempPo.setTotalMealsNumber(temporaryPO.getTotalMealsNumber());
		convertTempPo.setTotalMealsAmount(temporaryPO.getTotalMealsAmount());
		convertTempPo.setTotalTravelcostsStandard(temporaryPO.getTotalTravelcostsStandard());
		convertTempPo.setTotalTravelcostsDays(temporaryPO.getTotalTravelcostsDays());
		convertTempPo.setTotalTravelcostsNumber(temporaryPO.getTotalTravelcostsNumber());
		convertTempPo.setTotalTravelcostsAmount(temporaryPO.getTotalTravelcostsAmount());
		convertTempPo.setTotalHotelExpense(temporaryPO.getTotalHotelExpense());
		convertTempPo.setTotalOtherExpense(temporaryPO.getTotalOtherExpense());
		convertTempPo.setTotalSubtotal(temporaryPO.getTotalSubtotal());
		convertTempPo.setTotalMeetingFees(temporaryPO.getTotalMeetingFees());
		convertTempPo.setTotal(temporaryPO.getTotal());
		convertTempPo.setTotalCapital(temporaryPO.getTotalCapital());
		convertTempPo.setAmount(temporaryPO.getAmount());
		convertTempPo.setDates(DateUtils.dateToString(new Date(),"yyyy-MM-dd HH:mm:ss"));
		convertTempPo.setBudgetItem(temporaryPO.getBudgetItem());
		convertTempPo.setBudgetNature(temporaryPO.getBudgetNature());
		convertTempPo.setPkGroup("001");
		convertTempPo.setTaxAmount(null);
		convertTempPo.setGlobalbbje(temporaryPO.getAmount());
		convertTempPo.setOrgtaxAmount(null);
		convertTempPo.setSxbz("0");
		convertTempPo.setBzbm("CNY");
		convertTempPo.setPayflag("1");
		
		convertTempPo.setPkOrg("0001");
		convertTempPo.setVatAmount(temporaryPO.getAmount());
		convertTempPo.setPkFiorg("0001");
		convertTempPo.setBbje(temporaryPO.getAmount());
		convertTempPo.setFydwbm("0001");
		convertTempPo.setGroupBbje(temporaryPO.getAmount());
		convertTempPo.setTniAmount(temporaryPO.getAmount());
		convertTempPo.setDjdl("bx");
		convertTempPo.setSpzt("1");
		convertTempPo.setDjbh(null);
		convertTempPo.setJsfs(null);
		convertTempPo.setOrgtniAmount(temporaryPO.getAmount());
		convertTempPo.setDjrq(null);
		convertTempPo.setPayTarget("0");
		convertTempPo.setPkPayorg("0001");
		convertTempPo.setDjzt("1");
		convertTempPo.setDjlxbm(null);//交易类型编码
		convertTempPo.setDwbm("0001");
		convertTempPo.setOrgvatAmount(temporaryPO.getAmount());
		convertTempPo.setPkOrgv("0001");
		convertTempPo.setYbje(temporaryPO.getAmount());
		convertTempPo.setPkBilltype("2641");
		convertTempPo.setZyx2(temporaryPO.getZyx2());
		map.put("tempPO", tempPO);
		map.put("convertPO", convertTempPo);
		return map;
	}
	public String getDates(String date) throws ParseException {
		SimpleDateFormat sbf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date d=sbf.parse(date);
		String dateStr=sbf.format(d);
		return dateStr;
	}
}
